home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / telecomm / uwsrc.arc / WINPROC.C < prev    next >
C/C++ Source or Header  |  1989-04-29  |  3KB  |  129 lines

  1. /*
  2.  * This file contains subroutines which deal with other processes
  3.  */
  4. #include <obdefs.h>
  5. #include <gemdefs.h>
  6. #include <stdio.h>
  7. #include <osbind.h>
  8. #include <xbios.h>
  9. #include "wind.h"
  10. #include "uw.h"
  11. #include "windefs.h"
  12.  
  13. extern    char * environ;
  14.  
  15. extern struct wi_str w[];
  16. extern int fast;
  17. extern int    scr_x, scr_y, scr_w, scr_h;    /* size of screen */
  18. extern OBJECT    *menubar;
  19.  
  20. char cmdpath[40] = "e:\\bin\\*.*";
  21.                     /* Path for command execution */
  22. char cmdname[40] = "msh.prg";        /* Name of command to run */
  23. char cmdargs[40] = " ";            /* Arguments for command */
  24.  
  25. /*
  26.  * Exec process from dialog.
  27.  */
  28. int do_exec()
  29. {
  30.   int status = 0;
  31.   int confbutt;
  32.  
  33.   fsel_input(cmdpath, cmdname, &confbutt);
  34.   if (confbutt) {
  35.     extern char * rindex();
  36.     char cmdstr[80];
  37.     char cmdargv[40];
  38.     char *argv[20];
  39.     char * ind;
  40.     OBJECT *obj_tmp;
  41.     TEDINFO *ted_tmp;
  42.     int cx, cy, cw, ch, tmp;
  43.  
  44.     strcpy(cmdstr, cmdpath);
  45.       ind = rindex(cmdstr, '\\');
  46.       if (ind) * ++ind = '\0';
  47.     strcat(cmdstr, cmdname);
  48.     form_dial(FMD_START, 0, 0, 0, 0, scr_x, scr_y, scr_w, scr_h);
  49.                     /* save screen */
  50.  
  51.     rsrc_gaddr(R_TREE, PARAM, &obj_tmp);
  52.     ted_tmp = (TEDINFO *) obj_tmp[PARAMSTR].ob_spec;
  53.     strcpy(ted_tmp->te_ptext, cmdargs);
  54.     form_center(obj_tmp, &cx, &cy, &cw, &ch);
  55.     if (!fast) form_dial(FMD_GROW, 0, 0, 20, 10, cx, cy, cw, ch);
  56.     objc_draw(obj_tmp, 0, 5, cx, cy, cw, ch);
  57.     tmp = form_do(obj_tmp, PARAMSTR);
  58.     if (!fast) form_dial(FMD_SHRINK, 0, 0, 20, 10, cx, cy, cw, ch);
  59.     objc_change(obj_tmp, tmp, 0, cx, cy, cw, ch, NONE, 0);
  60.     if (tmp != OKEXEC) {
  61.       form_dial(FMD_FINISH, 0, 0, 0, 0, scr_x, scr_y, scr_w, scr_h);
  62.       return(0);
  63.     }
  64.     strcpy(cmdargs, ted_tmp->te_ptext);
  65.     strcpy(cmdargv, cmdargs);
  66.  
  67.     graf_mouse(M_OFF, NULL);    /* turn mouse off */
  68.     menu_bar(menubar, 0);     /* menu bar off */
  69.     Cconws("\033E\033e");    /* clear screen, cursor on */
  70.     ind = cmdargv;
  71.     argv[0] = cmdname;
  72.     tmp = 1;
  73.     while (*ind != '\0') {
  74.       while (*ind == ' ' && *ind != '\0'){
  75.         *ind = '\0';
  76.         ++ind;
  77.       }
  78.       argv[tmp++] = ind;
  79.       while (*ind != ' ' && *ind != '\0')
  80.         ++ind;
  81.     }
  82.     argv[tmp] = NULL;
  83.     status = execve(cmdstr, argv, environ);
  84.     sleep(1);
  85.     Cconws("\033E\033f");    /* clear screen, cursor off */
  86.     form_dial(FMD_FINISH, 0, 0, 0, 0, scr_x, scr_y, scr_w, scr_h);
  87.     menu_bar(menubar, 1);     /* menu bar on */
  88.     graf_mouse(M_ON, NULL);    /* turn mouse on */
  89.   }
  90.   return(status);
  91. }
  92.  
  93. /*
  94.  * Set current path with dialog.
  95.  */
  96. int do_path()
  97. {
  98.   int status = 0;
  99.   int confbutt;
  100.   char curpath[80];
  101.   char ignore[40] = "";
  102.   int drv;
  103.  
  104.   curpath[0] = Dgetdrv() + 'a';
  105.   curpath[1] = ':';
  106.   Dgetpath(curpath+2, 0);
  107.   strcat(curpath, "\\*.*");
  108.   fsel_input(curpath, ignore, &confbutt);
  109.   if (confbutt) {
  110.     extern char * index(), *rindex();
  111.     char * ind;
  112.     ind = index(curpath, ':');
  113.     if (ind) {
  114.       drv = *(ind - 1);
  115.       if (drv > '\\')
  116.         drv -= 'a';
  117.       else
  118.     drv -= 'A';
  119.       if (drv >= 0 && drv <= 15)
  120.         Dsetdrv(drv);
  121.     }
  122.     else
  123.       ind = curpath;
  124.     *rindex(ind, '\\') = 0;
  125.     status = Dsetpath(++ind);
  126.   }
  127.   return(status);
  128. }
  129.